package com.globalresources.business.impl;

import java.util.List;

import com.globalresources.business.inface.IRelationService;
import com.globalresources.dao.inface.IRelationDao;
import com.globalresources.po.Relation;

/**
 * @author aaron.lu(luzhiyuan) E-mail:atyuan.lu@gmail.com
 * @since 创建时间：Jul 14, 2009 4:09:43 PM
 */
public class RelationServiceImpl implements IRelationService{
	
	private IRelationDao relationDao;

	public void setRelationDao(IRelationDao relationDao) {
		this.relationDao = relationDao;
	}
	
	/**
	 * load relations
	*@author aaron.lu(luzhiyuan)
	*@param username
	*@param authority
	*@return
	 */
	public List<Relation> getRelations(String username, String authority){
		return relationDao.getRelations(username, authority);
	}
	
	/**
	 * count the relation
	*@author aaron.lu(luzhiyuan)
	*@param username
	*@param authority
	*@return
	 */
	public int countRelations(String username, String authority){
		return relationDao.countRelations(username, authority);
	}
	
	
	/**
	 * save relation
	*@author aaron.lu(luzhiyuan)
	*@param relation
	 */
	public void saveRelation(Relation relation){
		relationDao.save(relation);
	}
	
	/**
	 * update relation
	*@author aaron.lu(luzhiyuan)
	*@param relation
	 */
	public void updateRelation(Relation relation){
		relationDao.save(relation);
	}
	
	/**
	 * remove a relation
	*@author aaron.lu(luzhiyuan)
	*@param relation
	 */
	public void deleteRelation(Relation relation){
		relationDao.remove(relation);
	}
	
	/**
	 * load a relation
	*@author aaron.lu(luzhiyuan)
	*@param id
	*@return
	 */
	public Relation getRelation(Integer id){
		return relationDao.find(id);
	}
}
